package com.shujia.collection_;

import org.junit.Test;

import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;

public class ArrayListDemo1 {

    @Test
    public void test2() {
        List c1 = new ArrayList();
        c1.add(10);
        c1.add("abc");
        c1.add("bbb");
        c1.add("ccc");

        ListIterator iterator = c1.listIterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }

        iterator.add("ddd");
        System.out.println("------------------");
        while (iterator.hasPrevious()) {
            System.out.println(iterator.previous());
        }


    }


    @Test
    public void test1() {
        List list = new ArrayList<>();
        Person p1 = new Person("zs");
        Person p2 = new Person("ls");
        Person p3 = new Person("zs");
        list.add(p1);
        list.add(p2);
        list.add(p3);
        System.out.println(list);

//        list.remove(p1);
//        System.out.println(list);


        Person p4 = new Person("zs");
        list.remove(p4);
        System.out.println(list);
    }
}
